package com.nuonuo.nuo_xp;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;

/**
 * @author glsite.com
 * @version $Rev$
 * @des ${TODO}
 * @updateAuthor $Author$
 * @updateDes ${TODO}
 */
public class HMAC {
    private static String jiami_text="nuonuo";
    public static String get_mac_1(){
        try {
            SecretKey key = new SecretKeySpec("FridaHook".getBytes(), "HmacSHA1");
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(key);
            mac.update(jiami_text.getBytes());
            return Utils.byteToHexString(mac.doFinal());



        }catch (NoSuchAlgorithmException | InvalidKeyException e) {
            e.printStackTrace();
            return null;
        }


    }

    public static String get_mac_2(){
        try {
            SecretKey key = new SecretKeySpec("FridaHook".getBytes(), "HmacSHA1");
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(key);
            mac.update(jiami_text.getBytes(), 2, 5);
            return Utils.byteToHexString(mac.doFinal("123456".getBytes()));

        }catch (NoSuchAlgorithmException | InvalidKeyException e) {
            e.printStackTrace();
            return null;
        }

    }
}
